﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using FinalFantasy6Randomizer.Properties;

namespace FinalFantasy6Randomizer
{
    public partial class ConfigForm : Form
    {
        private List<List<Ff6Color>> bg;

        public ConfigForm()
        {
            InitializeComponent();
        }

        private void ConfigForm_Load(object sender, EventArgs e)
        {
            SetConfig();
        }

        private void SetConfig()
        {
            bg = new List<List<Ff6Color>>
                     {
                         new List<Ff6Color>
                             {
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                             },
                         new List<Ff6Color>
                             {
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                             },
                         new List<Ff6Color>
                             {
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                             },
                         new List<Ff6Color>
                             {
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                             },
                         new List<Ff6Color>
                             {
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                             },
                         new List<Ff6Color>
                             {
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                             },
                         new List<Ff6Color>
                             {
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                             },
                         new List<Ff6Color>
                             {
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                                 new Ff6Color(),
                             },
                     };

            bg[0][0].Red = Settings.Default.Bg1Color1R;
            bg[0][0].Green = Settings.Default.Bg1Color1G;
            bg[0][0].Blue = Settings.Default.Bg1Color1B;
            bg[0][1].Red = Settings.Default.Bg1Color2R;
            bg[0][1].Green = Settings.Default.Bg1Color2G;
            bg[0][1].Blue = Settings.Default.Bg1Color2B;
            bg[0][2].Red = Settings.Default.Bg1Color3R;
            bg[0][2].Green = Settings.Default.Bg1Color3G;
            bg[0][2].Blue = Settings.Default.Bg1Color3B;
            bg[0][3].Red = Settings.Default.Bg1Color4R;
            bg[0][3].Green = Settings.Default.Bg1Color4G;
            bg[0][3].Blue = Settings.Default.Bg1Color4B;
            bg[0][4].Red = Settings.Default.Bg1Color5R;
            bg[0][4].Green = Settings.Default.Bg1Color5G;
            bg[0][4].Blue = Settings.Default.Bg1Color5B;
            bg[0][5].Red = Settings.Default.Bg1Color6R;
            bg[0][5].Green = Settings.Default.Bg1Color6G;
            bg[0][5].Blue = Settings.Default.Bg1Color6B;
            bg[0][6].Red = Settings.Default.Bg1Color7R;
            bg[0][6].Green = Settings.Default.Bg1Color7G;
            bg[0][6].Blue = Settings.Default.Bg1Color7B;
            bg[1][0].Red = Settings.Default.Bg2Color1R;
            bg[1][0].Green = Settings.Default.Bg2Color1G;
            bg[1][0].Blue = Settings.Default.Bg2Color1B;
            bg[1][1].Red = Settings.Default.Bg2Color2R;
            bg[1][1].Green = Settings.Default.Bg2Color2G;
            bg[1][1].Blue = Settings.Default.Bg2Color2B;
            bg[1][2].Red = Settings.Default.Bg2Color3R;
            bg[1][2].Green = Settings.Default.Bg2Color3G;
            bg[1][2].Blue = Settings.Default.Bg2Color3B;
            bg[1][3].Red = Settings.Default.Bg2Color4R;
            bg[1][3].Green = Settings.Default.Bg2Color4G;
            bg[1][3].Blue = Settings.Default.Bg2Color4B;
            bg[1][4].Red = Settings.Default.Bg2Color5R;
            bg[1][4].Green = Settings.Default.Bg2Color5G;
            bg[1][4].Blue = Settings.Default.Bg2Color5B;
            bg[1][5].Red = Settings.Default.Bg2Color6R;
            bg[1][5].Green = Settings.Default.Bg2Color6G;
            bg[1][5].Blue = Settings.Default.Bg2Color6B;
            bg[1][6].Red = Settings.Default.Bg2Color7R;
            bg[1][6].Green = Settings.Default.Bg2Color7G;
            bg[1][6].Blue = Settings.Default.Bg2Color7B;
            bg[2][0].Red = Settings.Default.Bg3Color1R;
            bg[2][0].Green = Settings.Default.Bg3Color1G;
            bg[2][0].Blue = Settings.Default.Bg3Color1B;
            bg[2][1].Red = Settings.Default.Bg3Color2R;
            bg[2][1].Green = Settings.Default.Bg3Color2G;
            bg[2][1].Blue = Settings.Default.Bg3Color2B;
            bg[2][2].Red = Settings.Default.Bg3Color3R;
            bg[2][2].Green = Settings.Default.Bg3Color3G;
            bg[2][2].Blue = Settings.Default.Bg3Color3B;
            bg[2][3].Red = Settings.Default.Bg3Color4R;
            bg[2][3].Green = Settings.Default.Bg3Color4G;
            bg[2][3].Blue = Settings.Default.Bg3Color4B;
            bg[2][4].Red = Settings.Default.Bg3Color5R;
            bg[2][4].Green = Settings.Default.Bg3Color5G;
            bg[2][4].Blue = Settings.Default.Bg3Color5B;
            bg[2][5].Red = Settings.Default.Bg3Color6R;
            bg[2][5].Green = Settings.Default.Bg3Color6G;
            bg[2][5].Blue = Settings.Default.Bg3Color6B;
            bg[2][6].Red = Settings.Default.Bg3Color7R;
            bg[2][6].Green = Settings.Default.Bg3Color7G;
            bg[2][6].Blue = Settings.Default.Bg3Color7B;
            bg[3][0].Red = Settings.Default.Bg4Color1R;
            bg[3][0].Green = Settings.Default.Bg4Color1G;
            bg[3][0].Blue = Settings.Default.Bg4Color1B;
            bg[3][1].Red = Settings.Default.Bg4Color2R;
            bg[3][1].Green = Settings.Default.Bg4Color2G;
            bg[3][1].Blue = Settings.Default.Bg4Color2B;
            bg[3][2].Red = Settings.Default.Bg4Color3R;
            bg[3][2].Green = Settings.Default.Bg4Color3G;
            bg[3][2].Blue = Settings.Default.Bg4Color3B;
            bg[3][3].Red = Settings.Default.Bg4Color4R;
            bg[3][3].Green = Settings.Default.Bg4Color4G;
            bg[3][3].Blue = Settings.Default.Bg4Color4B;
            bg[3][4].Red = Settings.Default.Bg4Color5R;
            bg[3][4].Green = Settings.Default.Bg4Color5G;
            bg[3][4].Blue = Settings.Default.Bg4Color5B;
            bg[3][5].Red = Settings.Default.Bg4Color6R;
            bg[3][5].Green = Settings.Default.Bg4Color6G;
            bg[3][5].Blue = Settings.Default.Bg4Color6B;
            bg[3][6].Red = Settings.Default.Bg4Color7R;
            bg[3][6].Green = Settings.Default.Bg4Color7G;
            bg[3][6].Blue = Settings.Default.Bg4Color7B;
            bg[4][0].Red = Settings.Default.Bg5Color1R;
            bg[4][0].Green = Settings.Default.Bg5Color1G;
            bg[4][0].Blue = Settings.Default.Bg5Color1B;
            bg[4][1].Red = Settings.Default.Bg5Color2R;
            bg[4][1].Green = Settings.Default.Bg5Color2G;
            bg[4][1].Blue = Settings.Default.Bg5Color2B;
            bg[4][2].Red = Settings.Default.Bg5Color3R;
            bg[4][2].Green = Settings.Default.Bg5Color3G;
            bg[4][2].Blue = Settings.Default.Bg5Color3B;
            bg[4][3].Red = Settings.Default.Bg5Color4R;
            bg[4][3].Green = Settings.Default.Bg5Color4G;
            bg[4][3].Blue = Settings.Default.Bg5Color4B;
            bg[4][4].Red = Settings.Default.Bg5Color5R;
            bg[4][4].Green = Settings.Default.Bg5Color5G;
            bg[4][4].Blue = Settings.Default.Bg5Color5B;
            bg[4][5].Red = Settings.Default.Bg5Color6R;
            bg[4][5].Green = Settings.Default.Bg5Color6G;
            bg[4][5].Blue = Settings.Default.Bg5Color6B;
            bg[4][6].Red = Settings.Default.Bg5Color7R;
            bg[4][6].Green = Settings.Default.Bg5Color7G;
            bg[4][6].Blue = Settings.Default.Bg5Color7B;
            bg[5][0].Red = Settings.Default.Bg6Color1R;
            bg[5][0].Green = Settings.Default.Bg6Color1G;
            bg[5][0].Blue = Settings.Default.Bg6Color1B;
            bg[5][1].Red = Settings.Default.Bg6Color2R;
            bg[5][1].Green = Settings.Default.Bg6Color2G;
            bg[5][1].Blue = Settings.Default.Bg6Color2B;
            bg[5][2].Red = Settings.Default.Bg6Color3R;
            bg[5][2].Green = Settings.Default.Bg6Color3G;
            bg[5][2].Blue = Settings.Default.Bg6Color3B;
            bg[5][3].Red = Settings.Default.Bg6Color4R;
            bg[5][3].Green = Settings.Default.Bg6Color4G;
            bg[5][3].Blue = Settings.Default.Bg6Color4B;
            bg[5][4].Red = Settings.Default.Bg6Color5R;
            bg[5][4].Green = Settings.Default.Bg6Color5G;
            bg[5][4].Blue = Settings.Default.Bg6Color5B;
            bg[5][5].Red = Settings.Default.Bg6Color6R;
            bg[5][5].Green = Settings.Default.Bg6Color6G;
            bg[5][5].Blue = Settings.Default.Bg6Color6B;
            bg[5][6].Red = Settings.Default.Bg6Color7R;
            bg[5][6].Green = Settings.Default.Bg6Color7G;
            bg[5][6].Blue = Settings.Default.Bg6Color7B;
            bg[6][0].Red = Settings.Default.Bg7Color1R;
            bg[6][0].Green = Settings.Default.Bg7Color1G;
            bg[6][0].Blue = Settings.Default.Bg7Color1B;
            bg[6][1].Red = Settings.Default.Bg7Color2R;
            bg[6][1].Green = Settings.Default.Bg7Color2G;
            bg[6][1].Blue = Settings.Default.Bg7Color2B;
            bg[6][2].Red = Settings.Default.Bg7Color3R;
            bg[6][2].Green = Settings.Default.Bg7Color3G;
            bg[6][2].Blue = Settings.Default.Bg7Color3B;
            bg[6][3].Red = Settings.Default.Bg7Color4R;
            bg[6][3].Green = Settings.Default.Bg7Color4G;
            bg[6][3].Blue = Settings.Default.Bg7Color4B;
            bg[6][4].Red = Settings.Default.Bg7Color5R;
            bg[6][4].Green = Settings.Default.Bg7Color5G;
            bg[6][4].Blue = Settings.Default.Bg7Color5B;
            bg[6][5].Red = Settings.Default.Bg7Color6R;
            bg[6][5].Green = Settings.Default.Bg7Color6G;
            bg[6][5].Blue = Settings.Default.Bg7Color6B;
            bg[6][6].Red = Settings.Default.Bg7Color7R;
            bg[6][6].Green = Settings.Default.Bg7Color7G;
            bg[6][6].Blue = Settings.Default.Bg7Color7B;
            bg[7][0].Red = Settings.Default.Bg8Color1R;
            bg[7][0].Green = Settings.Default.Bg8Color1G;
            bg[7][0].Blue = Settings.Default.Bg8Color1B;
            bg[7][1].Red = Settings.Default.Bg8Color2R;
            bg[7][1].Green = Settings.Default.Bg8Color2G;
            bg[7][1].Blue = Settings.Default.Bg8Color2B;
            bg[7][2].Red = Settings.Default.Bg8Color3R;
            bg[7][2].Green = Settings.Default.Bg8Color3G;
            bg[7][2].Blue = Settings.Default.Bg8Color3B;
            bg[7][3].Red = Settings.Default.Bg8Color4R;
            bg[7][3].Green = Settings.Default.Bg8Color4G;
            bg[7][3].Blue = Settings.Default.Bg8Color4B;
            bg[7][4].Red = Settings.Default.Bg8Color5R;
            bg[7][4].Green = Settings.Default.Bg8Color5G;
            bg[7][4].Blue = Settings.Default.Bg8Color5B;
            bg[7][5].Red = Settings.Default.Bg8Color6R;
            bg[7][5].Green = Settings.Default.Bg8Color6G;
            bg[7][5].Blue = Settings.Default.Bg8Color6B;
            bg[7][6].Red = Settings.Default.Bg8Color7R;
            bg[7][6].Green = Settings.Default.Bg8Color7G;
            bg[7][6].Blue = Settings.Default.Bg8Color7B;

            battleMode.SelectedItem = Settings.Default.BattleMode;
            battleSpeed.SelectedItem = Settings.Default.BattleSpeed;
            messageSpeed.SelectedItem = Settings.Default.MessageSpeed;
            commandSet.SelectedItem = Settings.Default.CommandSet;
            gauge.SelectedItem = Settings.Default.Gauge;
            sound.SelectedItem = Settings.Default.Sound;
            cursor.SelectedItem = Settings.Default.Cursor;
            reequip.SelectedItem = Settings.Default.Reequip;
            //controller.SelectedItem = Settings.Default.Controller;
            magicOrder.SelectedItem = Settings.Default.MagicOrder;
            fontColor.Red = Settings.Default.FontColorR;
            fontColor.Green = Settings.Default.FontColorG;
            fontColor.Blue = Settings.Default.FontColorB;
            window.SelectedItem = Settings.Default.Window;
        }

        private void window_SelectedIndexChanged(object sender, EventArgs e)
        {
            SetWindowColor();
            SetPreview();
        }

        private void SetWindowColor()
        {
            switch ((string)window.SelectedItem)
            {
                case "1":
                    windowColor1.Red = bg[0][0].Red;
                    windowColor1.Green = bg[0][0].Green;
                    windowColor1.Blue = bg[0][0].Blue;
                    windowColor2.Red = bg[0][1].Red;
                    windowColor2.Green = bg[0][1].Green;
                    windowColor2.Blue = bg[0][1].Blue;
                    windowColor3.Red = bg[0][2].Red;
                    windowColor3.Green = bg[0][2].Green;
                    windowColor3.Blue = bg[0][2].Blue;
                    windowColor4.Red = bg[0][3].Red;
                    windowColor4.Green = bg[0][3].Green;
                    windowColor4.Blue = bg[0][3].Blue;
                    windowColor5.Red = bg[0][4].Red;
                    windowColor5.Green = bg[0][4].Green;
                    windowColor5.Blue = bg[0][4].Blue;
                    windowColor6.Red = bg[0][5].Red;
                    windowColor6.Green = bg[0][5].Green;
                    windowColor6.Blue = bg[0][5].Blue;
                    windowColor7.Red = bg[0][6].Red;
                    windowColor7.Green = bg[0][6].Green;
                    windowColor7.Blue = bg[0][6].Blue;

                    break;
                case "2":
                    windowColor1.Red = bg[1][0].Red;
                    windowColor1.Green = bg[1][0].Green;
                    windowColor1.Blue = bg[1][0].Blue;
                    windowColor2.Red = bg[1][1].Red;
                    windowColor2.Green = bg[1][1].Green;
                    windowColor2.Blue = bg[1][1].Blue;
                    windowColor3.Red = bg[1][2].Red;
                    windowColor3.Green = bg[1][2].Green;
                    windowColor3.Blue = bg[1][2].Blue;
                    windowColor4.Red = bg[1][3].Red;
                    windowColor4.Green = bg[1][3].Green;
                    windowColor4.Blue = bg[1][3].Blue;
                    windowColor5.Red = bg[1][4].Red;
                    windowColor5.Green = bg[1][4].Green;
                    windowColor5.Blue = bg[1][4].Blue;
                    windowColor6.Red = bg[1][5].Red;
                    windowColor6.Green = bg[1][5].Green;
                    windowColor6.Blue = bg[1][5].Blue;
                    windowColor7.Red = bg[1][6].Red;
                    windowColor7.Green = bg[1][6].Green;
                    windowColor7.Blue = bg[1][6].Blue;

                    break;
                case "3":
                    windowColor1.Red = bg[2][0].Red;
                    windowColor1.Green = bg[2][0].Green;
                    windowColor1.Blue = bg[2][0].Blue;
                    windowColor2.Red = bg[2][1].Red;
                    windowColor2.Green = bg[2][1].Green;
                    windowColor2.Blue = bg[2][1].Blue;
                    windowColor3.Red = bg[2][2].Red;
                    windowColor3.Green = bg[2][2].Green;
                    windowColor3.Blue = bg[2][2].Blue;
                    windowColor4.Red = bg[2][3].Red;
                    windowColor4.Green = bg[2][3].Green;
                    windowColor4.Blue = bg[2][3].Blue;
                    windowColor5.Red = bg[2][4].Red;
                    windowColor5.Green = bg[2][4].Green;
                    windowColor5.Blue = bg[2][4].Blue;
                    windowColor6.Red = bg[2][5].Red;
                    windowColor6.Green = bg[2][5].Green;
                    windowColor6.Blue = bg[2][5].Blue;
                    windowColor7.Red = bg[2][6].Red;
                    windowColor7.Green = bg[2][6].Green;
                    windowColor7.Blue = bg[2][6].Blue;

                    break;
                case "4":
                    windowColor1.Red = bg[3][0].Red;
                    windowColor1.Green = bg[3][0].Green;
                    windowColor1.Blue = bg[3][0].Blue;
                    windowColor2.Red = bg[3][1].Red;
                    windowColor2.Green = bg[3][1].Green;
                    windowColor2.Blue = bg[3][1].Blue;
                    windowColor3.Red = bg[3][2].Red;
                    windowColor3.Green = bg[3][2].Green;
                    windowColor3.Blue = bg[3][2].Blue;
                    windowColor4.Red = bg[3][3].Red;
                    windowColor4.Green = bg[3][3].Green;
                    windowColor4.Blue = bg[3][3].Blue;
                    windowColor5.Red = bg[3][4].Red;
                    windowColor5.Green = bg[3][4].Green;
                    windowColor5.Blue = bg[3][4].Blue;
                    windowColor6.Red = bg[3][5].Red;
                    windowColor6.Green = bg[3][5].Green;
                    windowColor6.Blue = bg[3][5].Blue;
                    windowColor7.Red = bg[3][6].Red;
                    windowColor7.Green = bg[3][6].Green;
                    windowColor7.Blue = bg[3][6].Blue;

                    break;
                case "5":
                    windowColor1.Red = bg[4][0].Red;
                    windowColor1.Green = bg[4][0].Green;
                    windowColor1.Blue = bg[4][0].Blue;
                    windowColor2.Red = bg[4][1].Red;
                    windowColor2.Green = bg[4][1].Green;
                    windowColor2.Blue = bg[4][1].Blue;
                    windowColor3.Red = bg[4][2].Red;
                    windowColor3.Green = bg[4][2].Green;
                    windowColor3.Blue = bg[4][2].Blue;
                    windowColor4.Red = bg[4][3].Red;
                    windowColor4.Green = bg[4][3].Green;
                    windowColor4.Blue = bg[4][3].Blue;
                    windowColor5.Red = bg[4][4].Red;
                    windowColor5.Green = bg[4][4].Green;
                    windowColor5.Blue = bg[4][4].Blue;
                    windowColor6.Red = bg[4][5].Red;
                    windowColor6.Green = bg[4][5].Green;
                    windowColor6.Blue = bg[4][5].Blue;
                    windowColor7.Red = bg[4][6].Red;
                    windowColor7.Green = bg[4][6].Green;
                    windowColor7.Blue = bg[4][6].Blue;

                    break;
                case "6":
                    windowColor1.Red = bg[5][0].Red;
                    windowColor1.Green = bg[5][0].Green;
                    windowColor1.Blue = bg[5][0].Blue;
                    windowColor2.Red = bg[5][1].Red;
                    windowColor2.Green = bg[5][1].Green;
                    windowColor2.Blue = bg[5][1].Blue;
                    windowColor3.Red = bg[5][2].Red;
                    windowColor3.Green = bg[5][2].Green;
                    windowColor3.Blue = bg[5][2].Blue;
                    windowColor4.Red = bg[5][3].Red;
                    windowColor4.Green = bg[5][3].Green;
                    windowColor4.Blue = bg[5][3].Blue;
                    windowColor5.Red = bg[5][4].Red;
                    windowColor5.Green = bg[5][4].Green;
                    windowColor5.Blue = bg[5][4].Blue;
                    windowColor6.Red = bg[5][5].Red;
                    windowColor6.Green = bg[5][5].Green;
                    windowColor6.Blue = bg[5][5].Blue;
                    windowColor7.Red = bg[5][6].Red;
                    windowColor7.Green = bg[5][6].Green;
                    windowColor7.Blue = bg[5][6].Blue;

                    break;
                case "7":
                    windowColor1.Red = bg[6][0].Red;
                    windowColor1.Green = bg[6][0].Green;
                    windowColor1.Blue = bg[6][0].Blue;
                    windowColor2.Red = bg[6][1].Red;
                    windowColor2.Green = bg[6][1].Green;
                    windowColor2.Blue = bg[6][1].Blue;
                    windowColor3.Red = bg[6][2].Red;
                    windowColor3.Green = bg[6][2].Green;
                    windowColor3.Blue = bg[6][2].Blue;
                    windowColor4.Red = bg[6][3].Red;
                    windowColor4.Green = bg[6][3].Green;
                    windowColor4.Blue = bg[6][3].Blue;
                    windowColor5.Red = bg[6][4].Red;
                    windowColor5.Green = bg[6][4].Green;
                    windowColor5.Blue = bg[6][4].Blue;
                    windowColor6.Red = bg[6][5].Red;
                    windowColor6.Green = bg[6][5].Green;
                    windowColor6.Blue = bg[6][5].Blue;
                    windowColor7.Red = bg[6][6].Red;
                    windowColor7.Green = bg[6][6].Green;
                    windowColor7.Blue = bg[6][6].Blue;

                    break;
                case "8":
                    windowColor1.Red = bg[7][0].Red;
                    windowColor1.Green = bg[7][0].Green;
                    windowColor1.Blue = bg[7][0].Blue;
                    windowColor2.Red = bg[7][1].Red;
                    windowColor2.Green = bg[7][1].Green;
                    windowColor2.Blue = bg[7][1].Blue;
                    windowColor3.Red = bg[7][2].Red;
                    windowColor3.Green = bg[7][2].Green;
                    windowColor3.Blue = bg[7][2].Blue;
                    windowColor4.Red = bg[7][3].Red;
                    windowColor4.Green = bg[7][3].Green;
                    windowColor4.Blue = bg[7][3].Blue;
                    windowColor5.Red = bg[7][4].Red;
                    windowColor5.Green = bg[7][4].Green;
                    windowColor5.Blue = bg[7][4].Blue;
                    windowColor6.Red = bg[7][5].Red;
                    windowColor6.Green = bg[7][5].Green;
                    windowColor6.Blue = bg[7][5].Blue;
                    windowColor7.Red = bg[7][6].Red;
                    windowColor7.Green = bg[7][6].Green;
                    windowColor7.Blue = bg[7][6].Blue;

                    break;
            }
        }

        private void SetPreview()
        {
            Image tlImage = null;
            Image trImage = null;
            Image blImage = null;
            Image brImage = null;
            Image tcImage = null;
            Image bcImage = null;
            Image clImage = null;
            Image crImage = null;
            Image bgImage = null;


            switch ((string)window.SelectedItem)
            {
                case "1":
                    tlImage = RecolorImage(Resources.tl1);
                    trImage = RecolorImage(Resources.tr1);
                    blImage = RecolorImage(Resources.bl1);
                    brImage = RecolorImage(Resources.br1);
                    tcImage = RecolorImage(Resources.tc1);
                    bcImage = RecolorImage(Resources.bc1);
                    clImage = RecolorImage(Resources.cl1);
                    crImage = RecolorImage(Resources.cr1);
                    bgImage = RecolorImage(Resources.bg1);

                    break;
                case "2":
                    tlImage = RecolorImage(Resources.tl2);
                    trImage = RecolorImage(Resources.tr2);
                    blImage = RecolorImage(Resources.bl2);
                    brImage = RecolorImage(Resources.br2);
                    tcImage = RecolorImage(Resources.tc2);
                    bcImage = RecolorImage(Resources.bc2);
                    clImage = RecolorImage(Resources.cl2);
                    crImage = RecolorImage(Resources.cr2);
                    bgImage = RecolorImage(Resources.bg2);

                    break;
                case "3":
                    tlImage = RecolorImage(Resources.tl3);
                    trImage = RecolorImage(Resources.tr3);
                    blImage = RecolorImage(Resources.bl3);
                    brImage = RecolorImage(Resources.br3);
                    tcImage = RecolorImage(Resources.tc3);
                    bcImage = RecolorImage(Resources.bc3);
                    clImage = RecolorImage(Resources.cl3);
                    crImage = RecolorImage(Resources.cr3);
                    bgImage = RecolorImage(Resources.bg3);

                    break;
                case "4":
                    tlImage = RecolorImage(Resources.tl4);
                    trImage = RecolorImage(Resources.tr4);
                    blImage = RecolorImage(Resources.bl4);
                    brImage = RecolorImage(Resources.br4);
                    tcImage = RecolorImage(Resources.tc4);
                    bcImage = RecolorImage(Resources.bc4);
                    clImage = RecolorImage(Resources.cl4);
                    crImage = RecolorImage(Resources.cr4);
                    bgImage = RecolorImage(Resources.bg4);

                    break;
                case "5":
                    tlImage = RecolorImage(Resources.tl5);
                    trImage = RecolorImage(Resources.tr5);
                    blImage = RecolorImage(Resources.bl5);
                    brImage = RecolorImage(Resources.br5);
                    tcImage = RecolorImage(Resources.tc5);
                    bcImage = RecolorImage(Resources.bc5);
                    clImage = RecolorImage(Resources.cl5);
                    crImage = RecolorImage(Resources.cr5);
                    bgImage = RecolorImage(Resources.bg5);

                    break;
                case "6":
                    tlImage = RecolorImage(Resources.tl6);
                    trImage = RecolorImage(Resources.tr6);
                    blImage = RecolorImage(Resources.bl6);
                    brImage = RecolorImage(Resources.br6);
                    tcImage = RecolorImage(Resources.tc6);
                    bcImage = RecolorImage(Resources.bc6);
                    clImage = RecolorImage(Resources.cl6);
                    crImage = RecolorImage(Resources.cr6);
                    bgImage = RecolorImage(Resources.bg6);

                    break;
                case "7":
                    tlImage = RecolorImage(Resources.tl7);
                    trImage = RecolorImage(Resources.tr7);
                    blImage = RecolorImage(Resources.bl7);
                    brImage = RecolorImage(Resources.br7);
                    tcImage = RecolorImage(Resources.tc7);
                    bcImage = RecolorImage(Resources.bc7);
                    clImage = RecolorImage(Resources.cl7);
                    crImage = RecolorImage(Resources.cr7);
                    bgImage = RecolorImage(Resources.bg7);

                    break;
                case "8":
                    tlImage = RecolorImage(Resources.tl8);
                    trImage = RecolorImage(Resources.tr8);
                    blImage = RecolorImage(Resources.bl8);
                    brImage = RecolorImage(Resources.br8);
                    tcImage = RecolorImage(Resources.tc8);
                    bcImage = RecolorImage(Resources.bc8);
                    clImage = RecolorImage(Resources.cl8);
                    crImage = RecolorImage(Resources.cr8);
                    bgImage = RecolorImage(Resources.bg8);

                    break;
            }

            tl.Image = tlImage;
            tr.Image = trImage;
            bl.Image = blImage;
            br.Image = brImage;
            tc1.Image = tcImage;
            tc2.Image = tcImage;
            tc3.Image = tcImage;
            tc4.Image = tcImage;
            tc5.Image = tcImage;
            tc6.Image = tcImage;
            tc7.Image = tcImage;
            tc8.Image = tcImage;
            bc1.Image = bcImage;
            bc2.Image = bcImage;
            bc3.Image = bcImage;
            bc4.Image = bcImage;
            bc5.Image = bcImage;
            bc6.Image = bcImage;
            bc7.Image = bcImage;
            bc8.Image = bcImage;
            cl1.Image = clImage;
            cl2.Image = clImage;
            cl3.Image = clImage;
            cl4.Image = clImage;
            cl5.Image = clImage;
            cl6.Image = clImage;
            cl7.Image = clImage;
            cl8.Image = clImage;
            cr1.Image = crImage;
            cr2.Image = crImage;
            cr3.Image = crImage;
            cr4.Image = crImage;
            cr5.Image = crImage;
            cr6.Image = crImage;
            cr7.Image = crImage;
            cr8.Image = crImage;
            bg1.Image = bgImage;
            bg2.Image = bgImage;
            bg3.Image = bgImage;
            bg4.Image = bgImage;
            bg5.Image = bgImage;
            bg6.Image = bgImage;
            bg7.Image = bgImage;
            bg8.Image = bgImage;
            bg9.Image = bgImage;
            bg10.Image = bgImage;
            bg11.Image = bgImage;
            bg12.Image = bgImage;
            bg13.Image = bgImage;
            bg14.Image = bgImage;
            bg15.Image = bgImage;
            bg16.Image = bgImage;


        }

        private Image RecolorImage(Bitmap image)
        {
            var newColor1 = windowColor1.RgbColor;
            var newColor2 = windowColor2.RgbColor;
            var newColor3 = windowColor3.RgbColor;
            var newColor4 = windowColor4.RgbColor;
            var newColor5 = windowColor5.RgbColor;
            var newColor6 = windowColor6.RgbColor;
            var newColor7 = windowColor7.RgbColor;

            Color oldColor;

            var retVal = new Bitmap(image.Width, image.Height);

            for (int i = 0; i < image.Width; i++)
            {
                for (int j = 0; j < image.Height; j++)
                {
                    oldColor = image.GetPixel(i, j);
                    if (oldColor == Color.FromArgb(0xff, 0x00, 0x00))
                        retVal.SetPixel(i, j, newColor1);
                    if (oldColor == Color.FromArgb(0xff, 0xff, 0x00))
                        retVal.SetPixel(i, j, newColor2);
                    if (oldColor == Color.FromArgb(0x00, 0xff, 0x00))
                        retVal.SetPixel(i, j, newColor3);
                    if (oldColor == Color.FromArgb(0x00, 0xff, 0xff))
                        retVal.SetPixel(i, j, newColor4);
                    if (oldColor == Color.FromArgb(0x00, 0x00, 0xff))
                        retVal.SetPixel(i, j, newColor5);
                    if (oldColor == Color.FromArgb(0xff, 0x00, 0xff))
                        retVal.SetPixel(i, j, newColor6);
                    if (oldColor == Color.FromArgb(0xff, 0xff, 0xff))
                        retVal.SetPixel(i, j, newColor7);
                }
            }

            return retVal;
        }

        private void SetWindowColorRed(ColorPicker picker, int colorIndex)
        {
            switch ((string)window.SelectedItem)
            {
                case "1":
                    bg[0][colorIndex].Red = picker.Red;

                    break;
                case "2":
                    bg[1][colorIndex].Red = picker.Red;

                    break;
                case "3":
                    bg[2][colorIndex].Red = picker.Red;

                    break;
                case "4":
                    bg[3][colorIndex].Red = picker.Red;

                    break;
                case "5":
                    bg[4][colorIndex].Red = picker.Red;

                    break;
                case "6":
                    bg[5][colorIndex].Red = picker.Red;

                    break;
                case "7":
                    bg[6][colorIndex].Red = picker.Red;

                    break;
                case "8":
                    bg[7][colorIndex].Red = picker.Red;

                    break;
            }
        }
        private void SetWindowColorGreen(ColorPicker picker, int colorIndex)
        {
            switch ((string)window.SelectedItem)
            {
                case "1":
                    bg[0][colorIndex].Green = picker.Green;

                    break;
                case "2":
                    bg[1][colorIndex].Green = picker.Green;

                    break;
                case "3":
                    bg[2][colorIndex].Green = picker.Green;

                    break;
                case "4":
                    bg[3][colorIndex].Green = picker.Green;

                    break;
                case "5":
                    bg[4][colorIndex].Green = picker.Green;

                    break;
                case "6":
                    bg[5][colorIndex].Green = picker.Green;

                    break;
                case "7":
                    bg[6][colorIndex].Green = picker.Green;

                    break;
                case "8":
                    bg[7][colorIndex].Green = picker.Green;

                    break;
            }
        }
        private void SetWindowColorBlue(ColorPicker picker, int colorIndex)
        {
            switch ((string)window.SelectedItem)
            {
                case "1":
                    bg[0][colorIndex].Blue = picker.Blue;

                    break;
                case "2":
                    bg[1][colorIndex].Blue = picker.Blue;

                    break;
                case "3":
                    bg[2][colorIndex].Blue = picker.Blue;

                    break;
                case "4":
                    bg[3][colorIndex].Blue = picker.Blue;

                    break;
                case "5":
                    bg[4][colorIndex].Blue = picker.Blue;

                    break;
                case "6":
                    bg[5][colorIndex].Blue = picker.Blue;

                    break;
                case "7":
                    bg[6][colorIndex].Blue = picker.Blue;

                    break;
                case "8":
                    bg[7][colorIndex].Blue = picker.Blue;

                    break;
            }
        }


        private void windowColor1_BlueChanged(object sender)
        {
            SetWindowColorBlue((ColorPicker)sender, 0);
            SetPreview();
        }

        private void windowColor1_GreenChanged(object sender)
        {
            SetWindowColorGreen((ColorPicker)sender, 0);
            SetPreview();
        }

        private void windowColor1_RedChanged(object sender)
        {
            SetWindowColorRed((ColorPicker)sender, 0);
            SetPreview();
        }

        private void windowColor2_BlueChanged(object sender)
        {
            SetWindowColorBlue((ColorPicker)sender, 1);
            SetPreview();
        }

        private void windowColor2_GreenChanged(object sender)
        {
            SetWindowColorGreen((ColorPicker)sender, 1);
            SetPreview();
        }

        private void windowColor2_RedChanged(object sender)
        {
            SetWindowColorRed((ColorPicker)sender, 1);
            SetPreview();
        }

        private void windowColor3_BlueChanged(object sender)
        {
            SetWindowColorBlue((ColorPicker)sender, 2);
            SetPreview();
        }

        private void windowColor3_GreenChanged(object sender)
        {
            SetWindowColorGreen((ColorPicker)sender, 2);
            SetPreview();
        }

        private void windowColor3_RedChanged(object sender)
        {
            SetWindowColorRed((ColorPicker)sender, 2);
            SetPreview();
        }

        private void windowColor4_BlueChanged(object sender)
        {
            SetWindowColorBlue((ColorPicker)sender, 3);
            SetPreview();
        }

        private void windowColor4_GreenChanged(object sender)
        {
            SetWindowColorGreen((ColorPicker)sender, 3);
            SetPreview();
        }

        private void windowColor4_RedChanged(object sender)
        {
            SetWindowColorRed((ColorPicker)sender, 3);
            SetPreview();
        }

        private void windowColor5_BlueChanged(object sender)
        {
            SetWindowColorBlue((ColorPicker)sender, 4);
            SetPreview();
        }

        private void windowColor5_GreenChanged(object sender)
        {
            SetWindowColorGreen((ColorPicker)sender, 4);
            SetPreview();
        }

        private void windowColor5_RedChanged(object sender)
        {
            SetWindowColorRed((ColorPicker)sender, 4);
            SetPreview();
        }

        private void windowColor6_BlueChanged(object sender)
        {
            SetWindowColorBlue((ColorPicker)sender, 5);
            SetPreview();
        }

        private void windowColor6_GreenChanged(object sender)
        {
            SetWindowColorGreen((ColorPicker)sender, 5);
            SetPreview();
        }

        private void windowColor6_RedChanged(object sender)
        {
            SetWindowColorRed((ColorPicker)sender, 5);
            SetPreview();
        }

        private void windowColor7_BlueChanged(object sender)
        {
            SetWindowColorBlue((ColorPicker)sender, 6);
            SetPreview();
        }

        private void windowColor7_GreenChanged(object sender)
        {
            SetWindowColorGreen((ColorPicker)sender, 6);
            SetPreview();
        }

        private void windowColor7_RedChanged(object sender)
        {
            SetWindowColorRed((ColorPicker)sender, 6);
            SetPreview();
        }

        private void resetColors_Click(object sender, EventArgs e)
        {
            ResetWindowColor();
            SetWindowColor();
            SetPreview();
        }

        private void ResetWindowColor()
        {
            switch ((string)window.SelectedItem)
            {
                case "1":
                    bg[0][0].Red = 25;
                    bg[0][0].Green = 28;
                    bg[0][0].Blue = 28;
                    bg[0][1].Red = 20;
                    bg[0][1].Green = 22;
                    bg[0][1].Blue = 22;
                    bg[0][2].Red = 16;
                    bg[0][2].Green = 16;
                    bg[0][2].Blue = 16;
                    bg[0][3].Red = 10;
                    bg[0][3].Green = 10;
                    bg[0][3].Blue = 10;
                    bg[0][4].Red = 5;
                    bg[0][4].Green = 6;
                    bg[0][4].Blue = 6;
                    bg[0][5].Red = 6;
                    bg[0][5].Green = 6;
                    bg[0][5].Blue = 17;
                    bg[0][6].Red = 5;
                    bg[0][6].Green = 5;
                    bg[0][6].Blue = 16;

                    break;
                case "2":
                    bg[1][0].Red = 14;
                    bg[1][0].Green = 15;
                    bg[1][0].Blue = 15;
                    bg[1][1].Red = 8;
                    bg[1][1].Green = 9;
                    bg[1][1].Blue = 9;
                    bg[1][2].Red = 7;
                    bg[1][2].Green = 8;
                    bg[1][2].Blue = 8;
                    bg[1][3].Red = 6;
                    bg[1][3].Green = 7;
                    bg[1][3].Blue = 7;
                    bg[1][4].Red = 5;
                    bg[1][4].Green = 6;
                    bg[1][4].Blue = 6;
                    bg[1][5].Red = 4;
                    bg[1][5].Green = 5;
                    bg[1][5].Blue = 5;
                    bg[1][6].Red = 1;
                    bg[1][6].Green = 2;
                    bg[1][6].Blue = 2;

                    break;
                case "3":
                    bg[2][0].Red = 7;
                    bg[2][0].Green = 13;
                    bg[2][0].Blue = 16;
                    bg[2][1].Red = 6;
                    bg[2][1].Green = 10;
                    bg[2][1].Blue = 13;
                    bg[2][2].Red = 4;
                    bg[2][2].Green = 7;
                    bg[2][2].Blue = 10;
                    bg[2][3].Red = 3;
                    bg[2][3].Green = 6;
                    bg[2][3].Blue = 7;
                    bg[2][4].Red = 2;
                    bg[2][4].Green = 4;
                    bg[2][4].Blue = 5;
                    bg[2][5].Red = 2;
                    bg[2][5].Green = 3;
                    bg[2][5].Blue = 4;
                    bg[2][6].Red = 10;
                    bg[2][6].Green = 15;
                    bg[2][6].Blue = 19;

                    break;
                case "4":
                    bg[3][0].Red = 17;
                    bg[3][0].Green = 12;
                    bg[3][0].Blue = 4;
                    bg[3][1].Red = 15;
                    bg[3][1].Green = 11;
                    bg[3][1].Blue = 4;
                    bg[3][2].Red = 14;
                    bg[3][2].Green = 9;
                    bg[3][2].Blue = 3;
                    bg[3][3].Red = 12;
                    bg[3][3].Green = 8;
                    bg[3][3].Blue = 2;
                    bg[3][4].Red = 19;
                    bg[3][4].Green = 21;
                    bg[3][4].Blue = 20;
                    bg[3][5].Red = 7;
                    bg[3][5].Green = 9;
                    bg[3][5].Blue = 8;
                    bg[3][6].Red = 4;
                    bg[3][6].Green = 6;
                    bg[3][6].Blue = 5;

                    break;
                case "5":
                    bg[4][0].Red = 13;
                    bg[4][0].Green = 11;
                    bg[4][0].Blue = 8;
                    bg[4][1].Red = 12;
                    bg[4][1].Green = 11;
                    bg[4][1].Blue = 8;
                    bg[4][2].Red = 12;
                    bg[4][2].Green = 10;
                    bg[4][2].Blue = 7;
                    bg[4][3].Red = 11;
                    bg[4][3].Green = 9;
                    bg[4][3].Blue = 6;
                    bg[4][4].Red = 10;
                    bg[4][4].Green = 8;
                    bg[4][4].Blue = 4;
                    bg[4][5].Red = 7;
                    bg[4][5].Green = 7;
                    bg[4][5].Blue = 4;
                    bg[4][6].Red = 2;
                    bg[4][6].Green = 2;
                    bg[4][6].Blue = 2;

                    break;
                case "6":
                    bg[5][0].Red = 19;
                    bg[5][0].Green = 19;
                    bg[5][0].Blue = 19;
                    bg[5][1].Red = 13;
                    bg[5][1].Green = 15;
                    bg[5][1].Blue = 15;
                    bg[5][2].Red = 10;
                    bg[5][2].Green = 12;
                    bg[5][2].Blue = 11;
                    bg[5][3].Red = 8;
                    bg[5][3].Green = 10;
                    bg[5][3].Blue = 9;
                    bg[5][4].Red = 6;
                    bg[5][4].Green = 8;
                    bg[5][4].Blue = 7;
                    bg[5][5].Red = 4;
                    bg[5][5].Green = 6;
                    bg[5][5].Blue = 5;
                    bg[5][6].Red = 1;
                    bg[5][6].Green = 3;
                    bg[5][6].Blue = 2;

                    break;
                case "7":
                    bg[6][0].Red = 15;
                    bg[6][0].Green = 21;
                    bg[6][0].Blue = 14;
                    bg[6][1].Red = 12;
                    bg[6][1].Green = 17;
                    bg[6][1].Blue = 11;
                    bg[6][2].Red = 9;
                    bg[6][2].Green = 15;
                    bg[6][2].Blue = 8;
                    bg[6][3].Red = 7;
                    bg[6][3].Green = 13;
                    bg[6][3].Blue = 6;
                    bg[6][4].Red = 5;
                    bg[6][4].Green = 10;
                    bg[6][4].Blue = 4;
                    bg[6][5].Red = 4;
                    bg[6][5].Green = 7;
                    bg[6][5].Blue = 4;
                    bg[6][6].Red = 2;
                    bg[6][6].Green = 5;
                    bg[6][6].Blue = 3;

                    break;
                case "8":
                    bg[7][0].Red = 20;
                    bg[7][0].Green = 12;
                    bg[7][0].Blue = 13;
                    bg[7][1].Red = 25;
                    bg[7][1].Green = 24;
                    bg[7][1].Blue = 22;
                    bg[7][2].Red = 20;
                    bg[7][2].Green = 19;
                    bg[7][2].Blue = 16;
                    bg[7][3].Red = 26;
                    bg[7][3].Green = 17;
                    bg[7][3].Blue = 0;
                    bg[7][4].Red = 25;
                    bg[7][4].Green = 13;
                    bg[7][4].Blue = 0;
                    bg[7][5].Red = 20;
                    bg[7][5].Green = 11;
                    bg[7][5].Blue = 0;
                    bg[7][6].Red = 4;
                    bg[7][6].Green = 4;
                    bg[7][6].Blue = 4;

                    break;
            }
        }

        private void cancel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Close();
        }

        private void save_Click(object sender, EventArgs e)
        {
            SaveSettings();
            Close();
        }

        private void SaveSettings()
        {
            Settings.Default.Bg1Color1R = bg[0][0].Red;
            Settings.Default.Bg1Color1G = bg[0][0].Green;
            Settings.Default.Bg1Color1B = bg[0][0].Blue;
            Settings.Default.Bg1Color2R = bg[0][1].Red;
            Settings.Default.Bg1Color2G = bg[0][1].Green;
            Settings.Default.Bg1Color2B = bg[0][1].Blue;
            Settings.Default.Bg1Color3R = bg[0][2].Red;
            Settings.Default.Bg1Color3G = bg[0][2].Green;
            Settings.Default.Bg1Color3B = bg[0][2].Blue;
            Settings.Default.Bg1Color4R = bg[0][3].Red;
            Settings.Default.Bg1Color4G = bg[0][3].Green;
            Settings.Default.Bg1Color4B = bg[0][3].Blue;
            Settings.Default.Bg1Color5R = bg[0][4].Red;
            Settings.Default.Bg1Color5G = bg[0][4].Green;
            Settings.Default.Bg1Color5B = bg[0][4].Blue;
            Settings.Default.Bg1Color6R = bg[0][5].Red;
            Settings.Default.Bg1Color6G = bg[0][5].Green;
            Settings.Default.Bg1Color6B = bg[0][5].Blue;
            Settings.Default.Bg1Color7R = bg[0][6].Red;
            Settings.Default.Bg1Color7G = bg[0][6].Green;
            Settings.Default.Bg1Color7B = bg[0][6].Blue;
            Settings.Default.Bg2Color1R = bg[1][0].Red;
            Settings.Default.Bg2Color1G = bg[1][0].Green;
            Settings.Default.Bg2Color1B = bg[1][0].Blue;
            Settings.Default.Bg2Color2R = bg[1][1].Red;
            Settings.Default.Bg2Color2G = bg[1][1].Green;
            Settings.Default.Bg2Color2B = bg[1][1].Blue;
            Settings.Default.Bg2Color3R = bg[1][2].Red;
            Settings.Default.Bg2Color3G = bg[1][2].Green;
            Settings.Default.Bg2Color3B = bg[1][2].Blue;
            Settings.Default.Bg2Color4R = bg[1][3].Red;
            Settings.Default.Bg2Color4G = bg[1][3].Green;
            Settings.Default.Bg2Color4B = bg[1][3].Blue;
            Settings.Default.Bg2Color5R = bg[1][4].Red;
            Settings.Default.Bg2Color5G = bg[1][4].Green;
            Settings.Default.Bg2Color5B = bg[1][4].Blue;
            Settings.Default.Bg2Color6R = bg[1][5].Red;
            Settings.Default.Bg2Color6G = bg[1][5].Green;
            Settings.Default.Bg2Color6B = bg[1][5].Blue;
            Settings.Default.Bg2Color7R = bg[1][6].Red;
            Settings.Default.Bg2Color7G = bg[1][6].Green;
            Settings.Default.Bg2Color7B = bg[1][6].Blue;
            Settings.Default.Bg3Color1R = bg[2][0].Red;
            Settings.Default.Bg3Color1G = bg[2][0].Green;
            Settings.Default.Bg3Color1B = bg[2][0].Blue;
            Settings.Default.Bg3Color2R = bg[2][1].Red;
            Settings.Default.Bg3Color2G = bg[2][1].Green;
            Settings.Default.Bg3Color2B = bg[2][1].Blue;
            Settings.Default.Bg3Color3R = bg[2][2].Red;
            Settings.Default.Bg3Color3G = bg[2][2].Green;
            Settings.Default.Bg3Color3B = bg[2][2].Blue;
            Settings.Default.Bg3Color4R = bg[2][3].Red;
            Settings.Default.Bg3Color4G = bg[2][3].Green;
            Settings.Default.Bg3Color4B = bg[2][3].Blue;
            Settings.Default.Bg3Color5R = bg[2][4].Red;
            Settings.Default.Bg3Color5G = bg[2][4].Green;
            Settings.Default.Bg3Color5B = bg[2][4].Blue;
            Settings.Default.Bg3Color6R = bg[2][5].Red;
            Settings.Default.Bg3Color6G = bg[2][5].Green;
            Settings.Default.Bg3Color6B = bg[2][5].Blue;
            Settings.Default.Bg3Color7R = bg[2][6].Red;
            Settings.Default.Bg3Color7G = bg[2][6].Green;
            Settings.Default.Bg3Color7B = bg[2][6].Blue;
            Settings.Default.Bg4Color1R = bg[3][0].Red;
            Settings.Default.Bg4Color1G = bg[3][0].Green;
            Settings.Default.Bg4Color1B = bg[3][0].Blue;
            Settings.Default.Bg4Color2R = bg[3][1].Red;
            Settings.Default.Bg4Color2G = bg[3][1].Green;
            Settings.Default.Bg4Color2B = bg[3][1].Blue;
            Settings.Default.Bg4Color3R = bg[3][2].Red;
            Settings.Default.Bg4Color3G = bg[3][2].Green;
            Settings.Default.Bg4Color3B = bg[3][2].Blue;
            Settings.Default.Bg4Color4R = bg[3][3].Red;
            Settings.Default.Bg4Color4G = bg[3][3].Green;
            Settings.Default.Bg4Color4B = bg[3][3].Blue;
            Settings.Default.Bg4Color5R = bg[3][4].Red;
            Settings.Default.Bg4Color5G = bg[3][4].Green;
            Settings.Default.Bg4Color5B = bg[3][4].Blue;
            Settings.Default.Bg4Color6R = bg[3][5].Red;
            Settings.Default.Bg4Color6G = bg[3][5].Green;
            Settings.Default.Bg4Color6B = bg[3][5].Blue;
            Settings.Default.Bg4Color7R = bg[3][6].Red;
            Settings.Default.Bg4Color7G = bg[3][6].Green;
            Settings.Default.Bg4Color7B = bg[3][6].Blue;
            Settings.Default.Bg5Color1R = bg[4][0].Red;
            Settings.Default.Bg5Color1G = bg[4][0].Green;
            Settings.Default.Bg5Color1B = bg[4][0].Blue;
            Settings.Default.Bg5Color2R = bg[4][1].Red;
            Settings.Default.Bg5Color2G = bg[4][1].Green;
            Settings.Default.Bg5Color2B = bg[4][1].Blue;
            Settings.Default.Bg5Color3R = bg[4][2].Red;
            Settings.Default.Bg5Color3G = bg[4][2].Green;
            Settings.Default.Bg5Color3B = bg[4][2].Blue;
            Settings.Default.Bg5Color4R = bg[4][3].Red;
            Settings.Default.Bg5Color4G = bg[4][3].Green;
            Settings.Default.Bg5Color4B = bg[4][3].Blue;
            Settings.Default.Bg5Color5R = bg[4][4].Red;
            Settings.Default.Bg5Color5G = bg[4][4].Green;
            Settings.Default.Bg5Color5B = bg[4][4].Blue;
            Settings.Default.Bg5Color6R = bg[4][5].Red;
            Settings.Default.Bg5Color6G = bg[4][5].Green;
            Settings.Default.Bg5Color6B = bg[4][5].Blue;
            Settings.Default.Bg5Color7R = bg[4][6].Red;
            Settings.Default.Bg5Color7G = bg[4][6].Green;
            Settings.Default.Bg5Color7B = bg[4][6].Blue;
            Settings.Default.Bg6Color1R = bg[5][0].Red;
            Settings.Default.Bg6Color1G = bg[5][0].Green;
            Settings.Default.Bg6Color1B = bg[5][0].Blue;
            Settings.Default.Bg6Color2R = bg[5][1].Red;
            Settings.Default.Bg6Color2G = bg[5][1].Green;
            Settings.Default.Bg6Color2B = bg[5][1].Blue;
            Settings.Default.Bg6Color3R = bg[5][2].Red;
            Settings.Default.Bg6Color3G = bg[5][2].Green;
            Settings.Default.Bg6Color3B = bg[5][2].Blue;
            Settings.Default.Bg6Color4R = bg[5][3].Red;
            Settings.Default.Bg6Color4G = bg[5][3].Green;
            Settings.Default.Bg6Color4B = bg[5][3].Blue;
            Settings.Default.Bg6Color5R = bg[5][4].Red;
            Settings.Default.Bg6Color5G = bg[5][4].Green;
            Settings.Default.Bg6Color5B = bg[5][4].Blue;
            Settings.Default.Bg6Color6R = bg[5][5].Red;
            Settings.Default.Bg6Color6G = bg[5][5].Green;
            Settings.Default.Bg6Color6B = bg[5][5].Blue;
            Settings.Default.Bg6Color7R = bg[5][6].Red;
            Settings.Default.Bg6Color7G = bg[5][6].Green;
            Settings.Default.Bg6Color7B = bg[5][6].Blue;
            Settings.Default.Bg7Color1R = bg[6][0].Red;
            Settings.Default.Bg7Color1G = bg[6][0].Green;
            Settings.Default.Bg7Color1B = bg[6][0].Blue;
            Settings.Default.Bg7Color2R = bg[6][1].Red;
            Settings.Default.Bg7Color2G = bg[6][1].Green;
            Settings.Default.Bg7Color2B = bg[6][1].Blue;
            Settings.Default.Bg7Color3R = bg[6][2].Red;
            Settings.Default.Bg7Color3G = bg[6][2].Green;
            Settings.Default.Bg7Color3B = bg[6][2].Blue;
            Settings.Default.Bg7Color4R = bg[6][3].Red;
            Settings.Default.Bg7Color4G = bg[6][3].Green;
            Settings.Default.Bg7Color4B = bg[6][3].Blue;
            Settings.Default.Bg7Color5R = bg[6][4].Red;
            Settings.Default.Bg7Color5G = bg[6][4].Green;
            Settings.Default.Bg7Color5B = bg[6][4].Blue;
            Settings.Default.Bg7Color6R = bg[6][5].Red;
            Settings.Default.Bg7Color6G = bg[6][5].Green;
            Settings.Default.Bg7Color6B = bg[6][5].Blue;
            Settings.Default.Bg7Color7R = bg[6][6].Red;
            Settings.Default.Bg7Color7G = bg[6][6].Green;
            Settings.Default.Bg7Color7B = bg[6][6].Blue;
            Settings.Default.Bg8Color1R = bg[7][0].Red;
            Settings.Default.Bg8Color1G = bg[7][0].Green;
            Settings.Default.Bg8Color1B = bg[7][0].Blue;
            Settings.Default.Bg8Color2R = bg[7][1].Red;
            Settings.Default.Bg8Color2G = bg[7][1].Green;
            Settings.Default.Bg8Color2B = bg[7][1].Blue;
            Settings.Default.Bg8Color3R = bg[7][2].Red;
            Settings.Default.Bg8Color3G = bg[7][2].Green;
            Settings.Default.Bg8Color3B = bg[7][2].Blue;
            Settings.Default.Bg8Color4R = bg[7][3].Red;
            Settings.Default.Bg8Color4G = bg[7][3].Green;
            Settings.Default.Bg8Color4B = bg[7][3].Blue;
            Settings.Default.Bg8Color5R = bg[7][4].Red;
            Settings.Default.Bg8Color5G = bg[7][4].Green;
            Settings.Default.Bg8Color5B = bg[7][4].Blue;
            Settings.Default.Bg8Color6R = bg[7][5].Red;
            Settings.Default.Bg8Color6G = bg[7][5].Green;
            Settings.Default.Bg8Color6B = bg[7][5].Blue;
            Settings.Default.Bg8Color7R = bg[7][6].Red;
            Settings.Default.Bg8Color7G = bg[7][6].Green;
            Settings.Default.Bg8Color7B = bg[7][6].Blue;

            Settings.Default.BattleMode = battleMode.SelectedItem.ToString();
            Settings.Default.BattleSpeed = battleSpeed.SelectedItem.ToString();
            Settings.Default.MessageSpeed = messageSpeed.SelectedItem.ToString();
            Settings.Default.CommandSet = commandSet.SelectedItem.ToString();
            Settings.Default.Gauge = gauge.SelectedItem.ToString();
            Settings.Default.Sound = sound.SelectedItem.ToString();
            Settings.Default.Cursor = cursor.SelectedItem.ToString();
            Settings.Default.Reequip = reequip.SelectedItem.ToString();
            //Settings.Default.Controller = controller.SelectedItem.ToString();
            Settings.Default.MagicOrder = magicOrder.SelectedItem.ToString();
            Settings.Default.FontColorR = fontColor.Red;
            Settings.Default.FontColorG = fontColor.Green;
            Settings.Default.FontColorB = fontColor.Blue;
            Settings.Default.Window = window.SelectedItem.ToString();

            Settings.Default.Save();
        }
    }
}
